home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.constraints;
-
- import sub_arctic.lib.interactor_consts;
- import sub_arctic.lib.interactor;
-
- /**
- * Class to provide a standard object/part encoding and to provide constants
- * for them that can be used to build constraints. These references can
- * denote standard parts within the local neighborhood of an object and
- * can be used as part of lightweight constraints that use minimal storage
- * (which are the default). These lightweight references are encoded in 6
- * bits: depended upon objects are encoded in 3 (high order) bits and parts
- * use another 3 (stored in the low order bits). In addition, lightweight
- * references store an orientation for type checking purposes.<p>
- *
- * Methods are provided for creating a new instance from an existing instance
- * by filling in the part portion only. This allows several of these objects
- * (i.e., PARENT) to be used as "constant factories" so we get a cleaner
- * notation (i.e., PARENT.W()).
- *
- * @author Scott Hudson
- */
-
- public class std_objpart_encoding implements std_encoding_consts {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** The encoding of the object and part for local object references and
- * standard parts. This is encoded in 6 bits with the high 3 being an
- * object reference code and the low 3 being a part designator code. */
- protected int _encoding = 0;
-
- /** The encoding of the object and part for local object references and
- * standard parts. This is encoded in 6 bits with the high 3 being an
- * object reference code and the low 3 being a part designator code. */
- public int encoding() {return _encoding;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** The orientation of this part. This should be one of the values:
- * std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, or
- * std_encoding_consts.NOT_ORIENTED. */
- protected int _orientation;
-
- /** The orientation of this part. This should be one of the values:
- * std_encoding_consts.HORIZONTAL, std_encoding_consts.VERTICAL, or
- * std_encoding_consts.NOT_ORIENTED. */
- public int orientation() {return _orientation;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Constructor for a local reference to a standard part.
- *
- * @param int obj_code value for object encoding. This must be between
- * zero and OBJCODE_MAX. Values outside this range
- * will be silently truncated.
- * @param int part_code value for part encoding. This must be between
- * zero and PARTCODE_MAX. Values outside this range
- * will be silently truncated.
- * @param int orient_code code for the orientation of this part. Should be
- * one of HORIZONTAL, VERTICAL, or NOT_ORIENTED
- */
- public std_objpart_encoding(int obj_code, int part_code, int orient_code)
- {
- _encoding = ((obj_code & OBJCODE_MASK) << OBJCODE_SHIFT) |
- ((part_code & PARTCODE_MASK) << PARTCODE_SHIFT);
- _orientation = orient_code;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Extract and return just the object designator encoding */
- public int object_encoded()
- {
- return (_encoding >> OBJCODE_SHIFT) & OBJCODE_MASK;
- }
-
- /** Extract and return just the object designator from the given encoding */
- public static int object_encoded(int enc)
- {
- return (enc >> OBJCODE_SHIFT) & OBJCODE_MASK;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Extract and return just the part designator encoding */
- public int part_encoded()
- {
- return (_encoding >> PARTCODE_SHIFT) & PARTCODE_MASK;
- }
-
- /** Extract and return just the part designator from the given encoding */
- public static int part_encoded(int enc)
- {
- return (enc >> PARTCODE_SHIFT) & PARTCODE_MASK;
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x part of this object */
- public std_objpart_encoding X()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_XY,HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x1 part of this object.
- * This does exactly the same thing as X(). */
- public std_objpart_encoding X1()
- {
- return X();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the left part of this object.
- * This does exactly the same thing as X(). */
- public std_objpart_encoding LEFT()
- {
- return X();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y part of this object */
- public std_objpart_encoding Y()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_XY, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y1 part of this object.
- * This does the exactly the same thing as Y(). */
- public std_objpart_encoding Y1()
- {
- return Y();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the top part of this object.
- * This does the exactly the same thing as Y(). */
- public std_objpart_encoding TOP()
- {
- return Y();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the x2 part of this object */
- public std_objpart_encoding X2()
- {
- return new std_objpart_encoding(object_encoded(),PARTCODE_XY2,HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the right part of this object.
- * This is the same as X2(). */
- public std_objpart_encoding RIGHT()
- {
- return X2();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the y2 part of this object */
- public std_objpart_encoding Y2()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_XY2, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
-
- /** Method returning an instance designating the bottom part of this object.
- * This is the same as Y2(). */
- public std_objpart_encoding BOTTOM()
- {
- return Y2();
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the w part of this object */
- public std_objpart_encoding W()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_WH,HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the h part of this object */
- public std_objpart_encoding H()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_WH, VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the horizontal center part of
- * this object */
- public std_objpart_encoding HCENTER()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_CENTER,
- HORIZONTAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the vertical center part of
- * this object */
- public std_objpart_encoding VCENTER()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_CENTER,
- VERTICAL);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "visible" part of this
- * object */
- public std_objpart_encoding VISIBLE()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_VISIBLE,
- NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "enabled" part of this
- * object */
- public std_objpart_encoding ENABLED()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_ENABLED,
- NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "part_a" part of this
- * object. */
- public std_objpart_encoding PART_A()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_PART_A,
- NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Method returning an instance designating the "part_b" part of this
- * object. */
- public std_objpart_encoding PART_B()
- {
- return new std_objpart_encoding(object_encoded(), PARTCODE_PART_B,
- NOT_ORIENTED);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-